package cn.ad.server.domain.ad;

import cn.ad.server.domain.enumration.AdFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;

public class Creative implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -999056029104444709L;

	static final String VERSION = "0";
	static final String CACHE_NAME = "creative";

	private long id;
	private Campaign campaign;
	private int campaignId;
	private String name;
	private String description;
	private AdFormat adFormat;

	private AdTemplate adTemplate;
	private String impressionTracking;
	private String clicksTracking;
	private Date createTime;
	private Date updateTime;
	private int status;
	private int interactionType;
	private long interactionId;
	private InteractionApp interactionApp;
	private InteractionRedirects interactionRedirects;
	private List<Integer> platformIds;
	private List<AuditPassedMarker> AuditPassedMarkers;
	private CreativeGroup creativeGroup;

	public List<AuditPassedMarker> getAuditPassedMarkers() {
		return AuditPassedMarkers;
	}

	public void setAuditPassedMarkers(List<AuditPassedMarker> auditPassedMarkers) {
		AuditPassedMarkers = auditPassedMarkers;
	}

	public CreativeGroup getCreativeGroup() {
		return creativeGroup;
	}

	public void setCreativeGroup(CreativeGroup creativeGroup) {
		this.creativeGroup = creativeGroup;
	}

	/*
	 * 创意类型:adMaterials,adMaterialGroups选择其一 根据private AdTemplate adTemplate;判断
	 * ==null 非原生 ！=null 原生
	 */
	private List<AdMaterial> adMaterials;
	private Set<AdMaterial> adMaterialSet;
	private List<AdMaterialGroup> adMaterialGroups;
	private Set<AdMaterialGroup> adMaterialGroupSet;

	public static String materialsIdsCacheKey(long creativeId) {
		return new StringBuilder(CACHE_NAME).append(":").append(VERSION).append(":").append(creativeId).append(":")
				.append("admaterial.ids").toString();
	}

	public static String materialGroupIdsCacheKey(long creativeId) {
		return new StringBuilder(CACHE_NAME).append(":").append(VERSION).append(":").append(creativeId).append(":")
				.append("admaterialgroup.ids").toString();
	}

	public static String cacheKey(long id) {
		return new StringBuilder(CACHE_NAME).append(":").append(VERSION).append(":").append(id).toString();
	}

	public String toCacheKey() {
		return new StringBuilder(CACHE_NAME).append(":").append(VERSION).append(":").append(this.getId()).toString();
	}

	public String userAndCreativeKey(String userId) {
		return new StringBuilder(userId).append(":").append(this.getId()).toString();
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Campaign getCampaign() {
		return campaign;
	}

	public void setCampaign(Campaign campaign) {
		this.campaign = campaign;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public AdFormat getAdFormat() {
		return adFormat;
	}

	public void setAdFormat(AdFormat adFormat) {
		this.adFormat = adFormat;
	}

	public AdTemplate getAdTemplate() {
		return adTemplate;
	}

	public void setAdTemplate(AdTemplate adTemplate) {
		this.adTemplate = adTemplate;
	}

	public String getImpressionTracking() {
		return impressionTracking;
	}

	public void setImpressionTracking(String impressionTracking) {
		this.impressionTracking = impressionTracking;
	}

	public String getClicksTracking() {
		return clicksTracking;
	}

	public void setClicksTracking(String clicksTracking) {
		this.clicksTracking = clicksTracking;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getInteractionType() {
		return interactionType;
	}

	public void setInteractionType(int interactionType) {
		this.interactionType = interactionType;
	}

	public long getInteractionId() {
		return interactionId;
	}

	public void setInteractionId(long interactionId) {
		this.interactionId = interactionId;
	}

	public InteractionApp getInteractionApp() {
		return interactionApp;
	}

	public void setInteractionApp(InteractionApp interactionApp) {
		this.interactionApp = interactionApp;
	}

	public InteractionRedirects getInteractionRedirects() {
		return interactionRedirects;
	}

	public void setInteractionRedirects(InteractionRedirects interactionRedirects) {
		this.interactionRedirects = interactionRedirects;
	}

	public List<AdMaterial> getAdMaterials() {
		return adMaterials;
	}

	public void setAdMaterials(List<AdMaterial> adMaterials) {
		this.adMaterials = adMaterials;
	}

	public List<AdMaterialGroup> getAdMaterialGroups() {
		return adMaterialGroups;
	}

	public void setAdMaterialGroups(List<AdMaterialGroup> adMaterialGroups) {
		this.adMaterialGroups = adMaterialGroups;
	}

	public List<Integer> getPlatformIds() {
		return platformIds;
	}

	public void setPlatformIds(List<Integer> platformIds) {
		this.platformIds = platformIds;
	}

	public boolean equals(Object arg0) {
		if(arg0 instanceof Creative){			
			return this.id==((Creative)arg0).id;
		}else{
			return super.equals(arg0);
		}
	}
	
	public int hashCode() {
		return Long.valueOf(id).hashCode();
	}

	public int getCampaignId() {
		return campaignId;
	}

	public void setCampaignId(int campaignId) {
		this.campaignId = campaignId;
	}

	public Set<AdMaterial> getAdMaterialSet() {
		return adMaterialSet;
	}

	public void setAdMaterialSet(Set<AdMaterial> adMaterialSet) {
		this.adMaterialSet = adMaterialSet;
	}

	public Set<AdMaterialGroup> getAdMaterialGroupSet() {
		return adMaterialGroupSet;
	}

	public void setAdMaterialGroupSet(Set<AdMaterialGroup> adMaterialGroupSet) {
		this.adMaterialGroupSet = adMaterialGroupSet;
	}
	
	
}
